import java.util.ArrayList;
import java.util.List;

// School 类
class School {
    private List<Department> departments; // 1..* 关系
    private List<Student> students; // 0..* 关系

    public School() {
        this.departments = new ArrayList<>();
        this.students = new ArrayList<>();
    }

    public void addDepartment(Department department) {
        departments.add(department);
    }

    public void addStudent(Student student) {
        students.add(student);
    }

    public List<Department> getDepartments() {
        return departments;
    }

    public List<Student> getStudents() {
        return students;
    }
}

// Department 类
class Department {
    private String name;
    private Instructor instructor; // 1..* 关系
    private List<Subject> subjects; // 1..* 关系

    public Department(String name, Instructor instructor) {
        this.name = name;
        this.instructor = instructor;
        this.subjects = new ArrayList<>();
    }

    public void addSubject(Subject subject) {
        subjects.add(subject);
    }

    public String getName() {
        return name;
    }

    public Instructor getInstructor() {
        return instructor;
    }

    public List<Subject> getSubjects() {
        return subjects;
    }
}

// Instructor 类
class Instructor {
    private String name;
    private Department department; // 1..* 关系
    private List<Subject> subjects; // 1..3 关系

    public Instructor(String name, Department department) {
        this.name = name;
        this.department = department;
        this.subjects = new ArrayList<>();
    }

    public void addSubject(Subject subject) {
        if (subjects.size() < 3) {
            subjects.add(subject);
        }
    }

    public String getName() {
        return name;
    }

    public Department getDepartment() {
        return department;
    }

    public List<Subject> getSubjects() {
        return subjects;
    }
}

// Subject 类
class Subject {
    private String name;

    public Subject(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}

// Student 类
class Student {
    private String name;
    private List<Subject> subjects; // 1..5 关系

    public Student(String name) {
        this.name = name;
        this.subjects = new ArrayList<>();
    }

    public void addSubject(Subject subject) {
        if (subjects.size() < 5) {
            subjects.add(subject);
        }
    }

    public String getName() {
        return name;
    }

    public List<Subject> getSubjects() {
        return subjects;
    }
}
